package com.mlong.admin.modular.unicomjs.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.kordar.admin.kernel.wrapper.QueryWrapperEntity;
import com.kordar.admin.modular.sys.entity.AdminEntity;
import com.kordar.datalist.DatalistService;
import com.kordar.datalist.ExcelDatalistService;
import com.kordar.datalist.ResultEntity;
import com.mlong.admin.modular.unicomjs.entity.AreaCode;
import com.mlong.admin.modular.unicomjs.service.AreaCodeService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@AllArgsConstructor
@Controller
@RequestMapping("unicomjs")
public class AreaCodeController {

    private final AreaCodeService areaCodeService;
    private final DatalistService datalistService;
    private final ExcelDatalistService excelDatalistService;

    @GetMapping("area-code/index")
    public String index(Model model) {
        model.addAttribute("data", datalistService.render(areaCodeService.list(), AreaCode.class));
        return "pages/modular/unicomjs/area-code/index";
    }

    @RequestMapping("area-code/excel-list")
    @ResponseBody
    public ResultEntity<Object> excel() {
        return new ResultEntity<>(excelDatalistService.render(areaCodeService.list(), AreaCode.class));
    }

}
